﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class D05_Quaternion2 : MonoBehaviour
{
    //四元数*四元数  旋转的累加
    private void Update1()
    {
        //   transform.Rotate(Vector3.up * Time.deltaTime * 30);
        transform.rotation = transform.rotation * Quaternion.Euler(0, 30 * Time.deltaTime, 0);
    }

    public GameObject bulletPrefab;//子弹预制体
    //四元数*向量   把这个向量,沿着四元数旋转后得到新的向量       把向量转一下
    private void Update()
    {
        //   (0,0,1)  绕y轴转90度得到  (1,0,0)

        //向四周均匀的角度发射36颗子弹
        if (Input.GetKeyDown(KeyCode.Space))
        {
            for (int i = 0; i < 36; i++)
            {
                //Instantiate(bulletPrefab, transform.position, Quaternion.Euler(0, i * 10, 0));
                var bullet = Instantiate(bulletPrefab, transform.position, Quaternion.identity);

                bullet.transform.forward = Quaternion.Euler(0, i * 10, 0) * transform.forward;
            }
        }
    }
}